/*   1:    */ package tt.dz.web.controller.user;
/*   2:    */ 
/*   3:    */ import com.alibaba.fastjson.JSON;
/*   4:    */ import java.util.ArrayList;
/*   5:    */ import java.util.HashMap;
/*   6:    */ import java.util.Iterator;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import javax.annotation.Resource;
/*  10:    */ import javax.servlet.http.HttpServletRequest;
/*  11:    */ import javax.servlet.http.HttpServletResponse;
/*  12:    */ import org.springframework.stereotype.Controller;
/*  13:    */ import org.springframework.web.bind.annotation.RequestMapping;
/*  14:    */ import org.springframework.web.bind.annotation.ResponseBody;
/*  15:    */ import tt.dz.biz.service.user.RoleService;
import tt.dz.common.DzConstants;
/*  16:    */ import tt.dz.common.DzConstants.bizSysCode;
/*  17:    */ import tt.dz.common.LogUtil;
/*  18:    */ import tt.dz.vo.ResponseModle;
/*  19:    */ import tt.dz.vo.RoleVO;
/*  20:    */ import tt.dz.web.controller.BaseController;
/*  21:    */ 
/*  22:    */ @Controller
/*  23:    */ public class RoleController
/*  24:    */   extends BaseController
/*  25:    */ {
/*  26:    */   @Resource(name="roleService")
/*  27:    */   private RoleService roleService;
/*  28:    */   
/*  29:    */   @RequestMapping(value={"/listAllRole"}, produces={"application/json;charset=UTF-8"})
/*  30:    */   @ResponseBody
/*  31:    */   public String listAllRole()
/*  32:    */   {
/*  33: 36 */     ResponseModle responseModle = null;
/*  34:    */     try
/*  35:    */     {
/*  36: 38 */       List<RoleVO> roleList = this.roleService.listAllRole();
/*  37: 39 */       responseModle = new ResponseModle("success", roleList);
/*  38:    */     }
/*  39:    */     catch (Exception e)
/*  40:    */     {
/*  41: 41 */       LogUtil.error("查询角色异常", e);
/*  42: 42 */       responseModle = new ResponseModle("error", new ArrayList());
/*  43:    */     }
/*  44: 44 */     return JSON.toJSONString(responseModle);
/*  45:    */   }
/*  46:    */   
/*  47:    */   @RequestMapping(value={"/mapAllRole"}, produces={"application/json;charset=UTF-8"})
/*  48:    */   @ResponseBody
/*  49:    */   public String mapAllRole()
/*  50:    */   {
/*  51: 53 */     ResponseModle responseModle = null;
/*  52:    */     try
/*  53:    */     {
/*  54: 55 */       List<RoleVO> roleList = this.roleService.listAllRole();
/*  55: 56 */       Iterator<RoleVO> iterator = roleList.iterator();
/*  56: 57 */       RoleVO roleVO = null;
/*  57: 58 */       Map<String, RoleVO> roleMap = new HashMap();
/*  58: 59 */       while (iterator.hasNext())
/*  59:    */       {
/*  60: 60 */         roleVO = (RoleVO)iterator.next();
/*  61: 61 */         roleMap.put(roleVO.getRoleId(), roleVO);
/*  62:    */       }
/*  63: 63 */       responseModle = new ResponseModle("success", roleMap);
/*  64:    */     }
/*  65:    */     catch (Exception e)
/*  66:    */     {
/*  67: 65 */       LogUtil.error("查询角色异常", e);
/*  68: 66 */       responseModle = new ResponseModle("error", new HashMap());
/*  69:    */     }
/*  70: 68 */     return JSON.toJSONString(responseModle);
/*  71:    */   }
/*  72:    */   
/*  73:    */   @RequestMapping(value={"/listAllValidRole"}, produces={"application/json;charset=UTF-8"})
/*  74:    */   @ResponseBody
/*  75:    */   public String listAllValidRole()
/*  76:    */   {
/*  77: 78 */     ResponseModle responseModle = null;
/*  78:    */     try
/*  79:    */     {
/*  80: 80 */       List<RoleVO> roleList = this.roleService.listAllValidRole();
/*  81: 81 */       responseModle = new ResponseModle("success", roleList);
/*  82:    */     }
/*  83:    */     catch (Exception e)
/*  84:    */     {
/*  85: 83 */       LogUtil.error("查询角色异常", e);
/*  86: 84 */       responseModle = new ResponseModle("error", new ArrayList());
/*  87:    */     }
/*  88: 86 */     return JSON.toJSONString(responseModle);
/*  89:    */   }
/*  90:    */   
/*  91:    */   @RequestMapping(value={"/modifyRole"}, produces={"application/json;charset=UTF-8"})
/*  92:    */   @ResponseBody
/*  93:    */   public String modifyRole(HttpServletRequest request, HttpServletResponse response)
/*  94:    */   {
/*  95: 98 */     boolean excuteFlag = false;
/*  96:    */     try
/*  97:    */     {
/*  98:100 */       String modifyType = request.getParameter("modifyType");
/*  99:101 */       RoleVO roleVO = (RoleVO)JSON.parseObject(request.getParameter("roleVO"), RoleVO.class);
/* 100:102 */       if ("insert".equals(modifyType)) {
/* 101:103 */         excuteFlag = this.roleService.insertRole(roleVO);
/* 102:104 */       } else if ("update".equals(modifyType)) {
/* 103:105 */         excuteFlag = this.roleService.updateRole(roleVO);
/* 104:    */       }
/* 105:    */     }
/* 106:    */     catch (Exception e)
/* 107:    */     {
/* 108:108 */       LogUtil.error("更改角色异常", e);
/* 109:    */     }
/* 110:110 */     return JSON.toJSONString(assemblyResponseData(excuteFlag, null));
/* 111:    */   }
/* 112:    */   
/* 113:    */   @RequestMapping(value={"/listMainServerRole"}, produces={"application/json;charset=UTF-8"})
/* 114:    */   @ResponseBody
/* 115:    */   public String listMainServerRole(HttpServletRequest request, HttpServletResponse response)
/* 116:    */   {
/* 117:121 */     ResponseModle responseModle = null;
/* 118:    */     try
/* 119:    */     {
/* 120:123 */       RoleVO roleVO = new RoleVO();
/* 121:124 */       roleVO.setSysCode(DzConstants.bizSysCode.MAIN_SERVER.value());
/* 122:125 */       List<RoleVO> roleList = this.roleService.queryRoleBySys(roleVO);
/* 123:126 */       responseModle = new ResponseModle("success", roleList);
/* 124:    */     }
/* 125:    */     catch (Exception e)
/* 126:    */     {
/* 127:128 */       LogUtil.error("查询角色异常", e);
/* 128:129 */       responseModle = new ResponseModle("error", new ArrayList());
/* 129:    */     }
/* 130:131 */     return JSON.toJSONString(responseModle);
/* 131:    */   }
/* 132:    */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.user.RoleController
 * JD-Core Version:    0.7.0.1
 */